package com.wenjie.original.service.impl;

import com.wenjie.common.utils.TokenUtil;
import com.wenjie.original.entity.OrderBoxAuthority;
import com.wenjie.original.entity.common.vo.RestBaseVo;
import com.wenjie.original.entity.vo.OrderBoxAuthority.OrderBoxAuthorityVo;
import com.wenjie.original.flex_config.baseInterface.Cus_ServiceImp;
import com.wenjie.original.mapper.OrderBoxAuthorityMapper;
import com.wenjie.original.service.IOrderBoxAuthorityService;
import com.wenjie.original.service.IOrderBoxService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;

/**
 * <p>
 * 打包计划的权限  服务实现类
 * </p>
 *
 * @author author
 * @since 2024-11-04 09:58:54
 */
@Service
public class OrderBoxAuthorityServiceImpl extends Cus_ServiceImp<OrderBoxAuthorityMapper, OrderBoxAuthority> implements IOrderBoxAuthorityService {

    @Autowired
    private IOrderBoxService orderBoxService;


    @Override
    public RestBaseVo<OrderBoxAuthorityVo.SelfResVo> slefList(OrderBoxAuthorityVo.SelfSelvo selvo) {


        OrderBoxAuthorityVo.SelVo selVo = new OrderBoxAuthorityVo.SelVo();
        selVo.setPn(1);
        selVo.setPs(9999);
        selVo.setOrderBoxId(selvo.getOrderBoxId());
        Long sysAdminId = TokenUtil.getTokenInfo().getId();
        selVo.setSysAdminId(sysAdminId);


        RestBaseVo<OrderBoxAuthorityVo.SelfResVo> list = this.list(selVo, OrderBoxAuthorityVo.SelfResVo.class);

        if (selvo.getSequence() == null) {
            return list;
        } else {

            RestBaseVo<OrderBoxAuthorityVo.SelfResVo> res = new RestBaseVo<>();
            res.setList(new ArrayList<>());

            //  0的意思是 全部的包装打包信息--不包括商品打包的信息
            if (selvo.getSequence() == 0) {
                for (OrderBoxAuthorityVo.SelfResVo selfResVo : list.getList()) {
                    if (selfResVo.getOrderBoxInfo().getOrderBoxBySequence() != 1) {
                        res.getList().add(selfResVo);
                    }
                }
                res.setMax(Long.valueOf(res.getList().size()));
                return res;
            } else {
                for (OrderBoxAuthorityVo.SelfResVo selfResVo : list.getList()) {
                    if (selfResVo.getOrderBoxInfo().getOrderBoxBySequence() == 1) {
                        res.getList().add(selfResVo);
                    }
                }
                res.setMax(Long.valueOf(res.getList().size()));
                return res;
            }
        }


    }
}
